const mysql2 = require('mysql2');

const connection = mysql2.createConnection({
    host: 'localhost',
    user: 'root',
    password: '123456',
    database: 'test'
});

const sqlFn = (sql, params, callback) => {
    connection.query(sql, params, (err, results) => {
        if (err) {
            console.error('数据库查询失败', err);
            return callback(err, null);
        }
        callback(null, results);
    });
};

module.exports = {
    sqlFn
};